import 'package:flutter/material.dart';
import 'package:aio/aio.dart';
import 'package:app/generated/app_strings.dart';
import 'package:app/src/http/bean/wroks/oem_auditing_product_bean.dart';
import 'package:app/src/manager/audit_manager.dart';
import 'package:app/src/presenter/review_presenter.dart';
import 'package:app/src/ui/app_ui.dart';
import 'package:app/src/ui/route/works/public/items/ui_attachment.dart';
import 'package:app/src/ui/route/works/public/items/ui_base.dart';
import 'package:app/src/ui/route/works/public/items/ui_contractInfo.dart';
import 'package:app/src/ui/route/works/public/items/ui_customersInfo.dart';
import 'package:app/src/ui/route/works/public/items/ui_new_customer.dart';
import 'package:app/src/ui/route/works/public/items/ui_node_list.dart';
import 'package:app/src/ui/route/works/public/items/ui_note.dart';
import 'package:app/src/ui/route/works/public/items/ui_oem_auditing.dart';
import 'package:app/src/ui/route/works/public/acom/ui_oem_auditing_product.dart';
import 'package:app/src/ui/route/works/public/acom/ui_order_item_info.dart';
import 'package:app/src/ui/route/works/public/items/ui_payment.dart';
import 'package:app/src/ui/route/works/public/acom/ui_process_info.dart';
import 'package:app/src/ui/route/works/public/items/ui_process_list.dart';
import 'package:app/src/ui/route/works/public/acom/ui_product.dart';
import 'package:app/src/ui/route/works/public/items/ui_product_info.dart';
import 'package:app/src/ui/route/works/public/items/ui_specialclauses.dart';
import 'package:app/src/ui/route/works/public/review_details_ui.dart';
import 'package:app/src/ui/route/works/public/review_submitted.dart';

///合同特殊设置审核详情
class ContractOemDetailsRoute extends StatefulWidget {
  ContractOemDetailsRoute();

  @override
  _State createState() => _State();
}

class _State extends State<ContractOemDetailsRoute> {
  _Presenter presenter = _Presenter();

  @override
  void initState() {
    super.initState();
    presenter.getContractapplygetinfoWithDelay(context); //获取审核详情数据
  }

  @override
  Widget build(BuildContext context) {
    return ReviewDetailsUi.build(context, presenter, _body);
  }

  Widget _body(BuildContext context) {
    if (presenter?.mDatas == null) {
      return AppUi.getEmptyView();
    }
    List<Widget> children = [];
    children.add(UiContractInfo.build(context, presenter?.mDatas?.ContractInfo,
        presenter?.mOldDatas?.ContractInfo,
        title: AppStrings.of(context).ContractInfo)); //基本信息（合同信息）
    var size = presenter?.mDatas?.OemAuditingList?.length;
    if (size != null && size > 0) {
      for (int i = 0; i < size; i++) {
        String title = "";
        if (i == 0) {
          title = AppStrings.of(context).TemplateTags0;
        } else if (i == 1) {
          title = AppStrings.of(context).TemplateTags1;
        } else if (i == 2) {
          title = AppStrings.of(context).TemplateTags2;
        } else if (i == 3) {
          title = AppStrings.of(context).TemplateTags3;
        } else if (i == 4) {
          title = AppStrings.of(context).TemplateTags4;
        } else if (i == 5) {
          title = AppStrings.of(context).TemplateTags5;
        } else if (i == 6) {
          title = AppStrings.of(context).TemplateTags6;
        }
        var data = presenter?.mDatas?.OemAuditingList?[i];
        var oldData = presenter?.mOldDatas?.OemAuditingList?[i];
        children.add(
            UiOemAuditing.build(context, data, oldData, title: title)); //标签模板
      }
    }
    children.add(UiOemAuditingProduct.build(context, presenter?.mDatas)); //产品设置
    children.add(UiNoteList.build(context, presenter?.mDatas?.NodeList)); //审核日志
    return Column(
      children: [
        Expanded(child: UiBase.listView(context, children)),
        Visibility(
            child: ReviewSubmittedStateful(
              presenter?.mDatas,
              hasEnd: false,
            ),
            visible: presenter?.mDatas != null)
      ],
    );
  }
}

class _Presenter extends ReviewPresenter {}
